export const regPhone = (curVal) => {
	const reg = /^(12[3]|13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '手机号码格式不正确'
}
export const regSum = (curVal) => {
	const reg = /^-?[1-9][0-9]?.?[0-9]*$/;
	const bool = reg.test(curVal)
	return bool ? '' : '请输入正确数量'
}
export const regGmail = (curVal) => {
	const reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '邮箱格式不正确'
}
export const regPhoneOrGmail = (curVal) => {
	if (!regPhone(curVal) || !regGmail(curVal)) {
		return ''
	}
	return '手机/邮箱格式不正确'
}

export const regVerification = (curVal) => {
	const bool = curVal.length > 5
	return bool ? '' : '验证码不正确'
}

export const regPassword = (curVal) => {
	const reg = /^(\w){5,20}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '密码格式不正确'
}
// 只能输入6-20个字母、数字、下划线

export const regPassword2 = (curVal, curVal2) => {
	const bool = curVal == curVal2
	return bool ? '' : '两次密码输入不同'
}

export const regPayPassword = (curVal, pwd) => {
	const reg = /^\d{6}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '交易密码格式为6位数字'
}

export const regPayPassword2 = (curVal, curVal2) => {
	const bool = curVal === curVal2
	return bool ? '' : '两次交易密码输入不同'
}

export const regInvite = (curVal) => {
	if (curVal) {
		const bool = curVal.length >= 6
		return bool ? '' : '请填写正确邀请码'
	} else {
		return '请填写邀请码'
	}
}

export const regName = (curVal) => {
	const reg = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/;
	const bool = reg.test(curVal)
	return bool ? '' : '姓名格式不正确'
}

export const regIdCards = (curVal) => {
	const reg =
		/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/;
	const bool = reg.test(curVal)
	return bool ? '' : '请输入正确的身份证号'
}

export const regBankCard = (curVal) => {
	const reg = /^([1-9]{1})(\d{14}|\d{18})$/;
	const bool = reg.test(curVal)
	return bool ? '' : '请输入正确的银行卡号'
}

export const regSubmit = (verify) => {
	const pwd = verify.password || ''
	const PayPwd= verify.payPassword || ''
	for (let i in verify) {
		switch (i) {
			case 'name':
				const rName = regName(verify[i])
				if (rName) return rName
				break;
			case 'phone':
				const rPhone = regPhone(verify[i])
				if (rPhone) return rPhone
				break;
			case 'sum':
				const rSum = regSum(verify[i])
				if (rSum) return rSum
				break;
			case 'verification':
				const rVerification = regVerification(verify[i])
				if (rVerification) return rVerification
				break;
			case 'phoneOrGmail':
				const rPhoneOrGmail = regPhoneOrGmail(verify[i])
				if (rPhoneOrGmail) return rPhoneOrGmail
				break;
			case 'password':
				const rPassword = regPassword(verify[i])
				if (rPassword) return rPassword
				break;
			case 'password2':
				const rPassword2 = regPassword2(verify[i], pwd)
				if (rPassword2) return rPassword2
				break;
			case 'payPassword':
				const pPassword = regPayPassword(verify[i], pwd)
				if (pPassword) return pPassword
				break;
			case 'payPassword2':
				const pPassword2 = regPayPassword2(verify[i], PayPwd)
				if (pPassword2) return pPassword2
				break;
			case 'invite':
				const rInvite = regInvite(verify[i])
				if (rInvite) return rInvite
				break;
			case 'IdCards':
				const rIdCards = regIdCards(verify[i])
				if (rIdCards) return rIdCards
				break;
			default:

		}
	}
}

export const ifVerif = (verify) => {
	const arr = Object.values(this.verify);
	for (const i of arr) {
		if (!i) {
			this.active = false
			break
			return
		}
		this.active = i
	}

}

